<?php
include './connect.php';
if(isset($_POST["txtLocation"])){
    $strSQL="INSERT INTO `Location`(`Location`) VALUES ('".$_POST["txtLocation"]."')";   
    mysqli_query($MechanicDB, $strSQL) or die(mysqli_error($MechanicDB));
    echo 'success';
    return false;
}
?>

<html>
    <head>
        <?php
            include 'sethead.php';
        ?>
        <title>Add Location</title>
        <script>
            $(document).ready(function(){
               $("#btClose").click(function(){
                  //alert("close");
                  parent.$.fancybox.close();
               });
               $("#btSubmit").click(function(){
                   if($("#txtLocation").val()==""){
                       $.Zebra_Dialog('Please input Location',{
                        'type':'warning',
                        'title':'Warning',
                        onClose:function(){
                            $("#txtLocation").focus();
                        }
                    });
                    return false;
                   }
                   $.post(
                       "frmAddLocation.php",
                       {
                           txtLocation : $("#txtLocation").val()
                       },
                       function(data){
                           if(data == "success"){
                              $.Zebra_Dialog('Insert Success',{'type':'confirmation','title':'Succress'});
                           }else{
                              $.Zebra_Dialog('Insert Error',{'type':'error','title':'Error'});
                           }
                          //alert(data);
                       }
                   );
               });
            });
        </script>
    </head>
    <body class="center">
        <div class="headpage">
            Add New Location
        </div>
        <div class="bodypage">
            Location : 
            <input type="text" id="txtLocation">
        </div>
        <div class="footpage">
            <button id="btSubmit">Submit</button>
            <button id="btClose">Close</button>
        </div>
    </body>
</html>